package com.anda.logistics.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.anda.logistics.model.SystemMenu;
import com.anda.logistics.model.SystemUser;
import com.anda.logistics.service.SystemMenuService;

@Controller("ManagerIndexAction")
@Scope("prototype")
public class ManagerIndexAction extends AndaBaseAction{

	private static final long serialVersionUID = -4551336268234044145L;
	private SystemMenuService systemMenuService;
	private List<SystemMenu> allMenu;
	
	@Actions(value=
		{@Action(value="/manager/",results=@Result(location="index.jsp",name="success")),
		 @Action(value="/manager/index",results=@Result(location="index.jsp",name="success"))
		}
	)
	public String execute(){
		SystemUser user = (SystemUser) request.getSession().getAttribute("user");
		allMenu = systemMenuService.getUserMenus(user);
		return SUCCESS;
	}

	public SystemMenuService getSystemMenuService() {
		return systemMenuService;
	}
	@Resource
	public void setSystemMenuService(SystemMenuService systemMenuService) {
		this.systemMenuService = systemMenuService;
	}

	public List<SystemMenu> getAllMenu() {
		return allMenu;
	}

	public void setAllMenu(List<SystemMenu> allMenu) {
		this.allMenu = allMenu;
	}
	
}
